import * as fs from 'fs'

interface Middleware {
  [name: string]: any
}

const middlewareExport: Middleware = {} as Middleware

fs.readdirSync(__dirname).forEach((file) => {
  if (file.includes('index')) return
  const middleware = require(`./${file}`).default
  middlewareExport[file.split('.')[0]] = middleware
})

export default middlewareExport

